package sorting;

public class Util {

	public static void swap (Object [] array, int x, int y){
		Object temp = array[x];
		array[x] = array[y];
		array[y] = temp;
	}	
	
	/**
	 * Example : [2, 3, 45, 5, 58]
	 * 
	 * @param array
	 * @return
	 */
	public static String toString(Object[] array){
		StringBuilder build = new StringBuilder();
		
		build.append("[");
		
		for (int i=0; i< array.length; i++){
			build.append(array[i].toString());
			
			if (i < array.length - 1)
				build.append(", ");
		}
		
		build.append("]");
		
		return build.toString();
	}
	
	   // Instantiates a Generic Type
    public static <D> D getInstance(Class<D> _class) {
            try {
                  return _class.newInstance();
            } catch (Exception _ex) {
                    _ex.printStackTrace();
            }
            return null;
    }
	
	
}
